#include <stdio.h>
#include <stdlib.h>

#include "../../libs/Utils/Utils.h"
#include "../../libs/LocalStack/LocalStack.h"

#include "../../libs/SparceMatrix/sparse_matrix.h"
#include "../../libs/SparceMatrix/LinearIO.h"

int main()
{
	int matrixSize;
	elem* inputVec, *outputVec;
	sparse_matrix_lst* matrix;
	
	InitGlobalStack();
	START();
	
	Assert(scanf("%d", &matrixSize) > 0);
	Assert(matrixSize > 0);
	SAFED(matrix = allocate_sparse_matrix_lst(matrixSize), free_sparse_matrix_lst);
	outputVec = (elem*)NEW(sizeof(elem) * matrixSize);
	inputVec = (elem*)NEW(sizeof(elem) * matrixSize);
	
	Assert(ScanInMatrix(matrix, stdin) != NULL);
	Assert(ScanInVector(matrixSize, inputVec));
	
	mult_sparse_list(matrix, inputVec, outputVec);
	Assert(PrintOutVector(matrixSize, outputVec));
	
	MDelete(3, matrix, inputVec, outputVec);
	
	RETURN(0);
}
